prune: Error if --static-deltas-only without --delete-commit
authorColin Walters <walters@verbum.org>
Mon, 5 Mar 2018 15:42:19 +0000 (10:42 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 5 Mar 2018 17:39:35 +0000 (17:39 +0000)
The original changes here apparently had the *idea* that `--static-deltas-only`
would be useful in general, but we never implemented that.  The current
situation where it's ignored unless `--delete-commit` is specified is
very misleading and I can easily see it leading to data loss for people.

Let's error out until we have a chance to make it actually useful.

Related: https://github.com/ostreedev/ostree/issues/1479

Closes: #1482
Approved by: giuseppe

src/ostree/ot-builtin-prune.c
tests/test-prune.sh

index 3f39dfe8f4076217d855e934988314977e45fb61..c34bbf4c02d60f1a554e04b43490cc081942b062 100644 (file)
@@ -174,6 +174,15 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
         else if (!delete_commit (repo, opt_delete_commit, cancellable, error))
           return FALSE;
     }
+  else
+    {
+      /* In the future we should make this useful, but for now let's
+       * error out since what we were doing before was very misleading.
+       * https://github.com/ostreedev/ostree/issues/1479
+       */
+      if (opt_static_deltas_only)
+        return glnx_throw (error, "--static-deltas-only requires --delete-commit; see https://github.com/ostreedev/ostree/issues/1479");
+    }
 
   OstreeRepoPruneFlags pruneflags = 0;
   if (opt_refs_only)
index 7de372c8a0fdd63bebc3f58703114d4cc2feee13..e8734801982c78b486afa7fc17b6d41e11c9b12a 100755 (executable)
@@ -141,9 +141,10 @@ assert_file_has_content deltascount "^1$"
 ${CMD_PREFIX} ostree --repo=repo static-delta generate test
 ${CMD_PREFIX} ostree --repo=repo static-delta list | wc -l > deltascount
 assert_file_has_content deltascount "^2$"
-${CMD_PREFIX} ostree --repo=repo prune --static-deltas-only --keep-younger-than="October 20 2015"
-${CMD_PREFIX} ostree --repo=repo static-delta list | wc -l > deltascount
-assert_file_has_content deltascount "^1$"
+if ${CMD_PREFIX} ostree --repo=repo prune --static-deltas-only --keep-younger-than="October 20 2015" 2>err.txt; then
+    fatal "pruned deltas only"
+fi
+assert_file_has_content_literal err.txt "--static-deltas-only requires --delete-commit"
 
 echo "ok prune"